import request from '@/utils/request'

// 获取路由
export const getProductCostIncome = (params) => {
  return request({
    url: '/analysis/productCostIncome',
    method: 'get',
    params
  })
}

// 导入历史记录
export const getShopImportHistory = (params) => {
  return request({
    url: '/shop/import/history',
    method: 'get',
    params
  })
}

// 店铺列表
export const getStoreManagement = (params) => {
  return request({
    url: '/shop/manage',
    method: 'get',
    params
  })
}

// 店铺新增
export const newStoreManagement = (params) => {
  return request({
    url: '/shop/manage',
    method: 'post',
    data: params
  })
}

// 店铺删除
export const deleteStoreManagement = (id) => {
  return request({
    url: '/shop/manage/' + id,
    method: 'delete',
  })
}

// 店铺查看
export const checkStoreManagement = (id) => {
  return request({
    url: '/shop/manage/' + id,
    method: 'get',
  })
}

// 店铺修改
export const editStoreManagement = (params) => {
  return request({
    url: '/shop/manage/update',
    method: 'post',
    data: params
  })
}

// 店铺修改
export const getAllStoreManagement = () => {
  return request({
    url: '/shop/manage/all',
    method: 'get',
  })
}

// 推广列表
export const getProductPromotion = (params) => {
  return request({
    url: '/analysis/productPromotion',
    method: 'get',
    params
  })
}

// 订单列表
export const getShopOrders = (params) => {
  return request({
    url: '/analysis/shopOrders',
    method: 'get',
    params
  })
}

// 导出列表
export const exportShopOrders = (params) => {
  return request({
    url: '/analysis/export',
    method: 'post',
    data: params
  })
}

// 单品分析
export const getProduct = (params) => {
  return request({
    url: '/analysis/product',
    method: 'get',
    params
  })
}

// 单品分析
export const updateLastCost = ({id, productLatestCost}) => {
  return request({
    url: `/productCostIncome/updateLastCost/${id}`,
    method: 'post',
    data: {
      productLatestCost
    }
  })
}

